package com.woniuxy.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.woniuxy.entity.Demand;
import com.woniuxy.entity.DisRequirements;
import com.woniuxy.entity.WareHousing;

@Mapper
public interface DemandMapper {
	//查询需求单
	@Select("select * from t_demand")
	public List<Demand> findDemand();
	
	//通过单号查询需求单
	@Select("select * from t_demand where orderno=#{orderno}")
	public Demand findDetailByOrderno(String orderno);
	
	//向需求单插入数据
	@Insert("insert into t_demand values(default,#{orderno},#{line},#{category},#{warehousing},"
			+ "#{weight},#{num},#{quality},#{time},#{status},#{wname},#{rname},#{client},#{department},#{effect},#{specifications})")
	public int insertDemand(Demand demand);
	
	//编辑需求单
	@Update("update t_demand set line=#{line},category=#{category},quality=#{quality},warehousing=#{warehousing},time=#{time} where orderno=#{orderno}")
	public int updateDemandByOrderno(Demand demand);

	//删除需求单
	@Delete("delete from t_demand where orderno=#{orderno}")
	public int delDemandByOrderno(String orderno);
	
	//提交一条数据
	@Insert("insert into t_distribution_requirements values(default,#{orderno},#{supplier},#{department},"
			+ "#{weight},#{num},#{wname},#{rname},#{time},#{status},#{line},#{category},#{storehome},#{quality})")
	public int insertDisprocurement(DisRequirements dis);
	
	//提交后修改状态
	@Update("update t_demand set status=#{status} where orderno=#{orderno}")
	public int changeStatus(Demand demand);
	
	//查询库存
	@Select("select * from t_warehousing")
	public List<WareHousing> findWarehousing();
}
